//
//  SpineTestViewController.m
//  JiZhuiAn
//
//  Created by Easy.Lin on 16/6/20.
//  Copyright © 2016年 Easy. All rights reserved.
//

#import "SpineTestViewController.h"
#import "SpecificTrainingViewController.h"

@interface SpineTestViewController ()

@end

@implementation SpineTestViewController

@dynamic viewModel;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIBarButtonItem *submitButton = [[UIBarButtonItem alloc]initWithTitle:@"提交" style:UIBarButtonItemStyleDone target:self action:@selector(getAnswersPressed:)];
    self.navigationItem.rightBarButtonItem = submitButton;
    submitButton.rac_command = self.viewModel.submitCommand;
    
}

- (void)viewSetting
{
    self.view.backgroundColor = backgroundWhiteColor;
}

- (void)addQuestion:(NSString *)question andAnswer:(NSArray *)answerArray
{
    NSDictionary *answer1 = [NSDictionary dictionaryWithObjectsAndKeys:[answerArray objectAtIndex:0],@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *answer2 = [NSDictionary dictionaryWithObjectsAndKeys:[answerArray objectAtIndex:1],@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *answer3 = [NSDictionary dictionaryWithObjectsAndKeys:[answerArray objectAtIndex:2],@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *answer4 = [NSDictionary dictionaryWithObjectsAndKeys:[answerArray objectAtIndex:3],@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *answer5 = [NSDictionary dictionaryWithObjectsAndKeys:[answerArray objectAtIndex:4],@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *answer6 = [NSDictionary dictionaryWithObjectsAndKeys:[answerArray objectAtIndex:5],@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    GWQuestionnaireItem *item = [[GWQuestionnaireItem alloc] initWithQuestion:question
                                                                      answers:[NSArray arrayWithObjects:answer1,answer2,answer3,answer4,answer5,answer6,nil]
                                                                         type:GWQuestionnaireSingleChoice];
    [questions addObject:item];
    
}

- (void)createQuestionaire
{
    questions = [NSMutableArray array];
    //颈部
    [self addQuestion:@"1. 颈肩部有无压痛点" andAnswer:@[@"A. 有，且不压就感觉到痛",@"B. 有，但压痛不明显",@"C. 无明显压痛点"]];
    [self addQuestion:@"2. 头颈部前屈后伸，左右转动，有无骨关节摩擦音及韧带滑动弹响声" andAnswer:@[@"A. 有，且明显",@"B. 偶尔过度疲劳才会出现",@"C. 无明显声响"]];
    [self addQuestion:@"3. 肩颈部是否经常出现僵硬酸痛" andAnswer:@[@"A. 有，且明显",@"B. 偶尔过度疲劳才会出现",@"C. 无明显僵硬酸痛"]];
    [self addQuestion:@"4. 两眼平视，下颌内收，左右旋转可达到60°~80" andAnswer:@[@"A. 未能及60°",@"B. 勉强做到",@"C. 轻松做到"]];
    [self addQuestion:@"5. 两眼平视，下颌内收，前屈后仰可达到35°~50°" andAnswer:@[@"A. 未能及35°",@"B. 勉强做到",@"C. 轻松做到"]];
    [self addQuestion:@"6. 两眼平视，下颌内收，左右侧屈可以达到40°" andAnswer:@[@"A. 未能及40°",@"B. 勉强做到",@"C. 轻松做到"]];
    
    //腰部
    [self addQuestion:@"1. 坐立时腰部会出现疼痛症状" andAnswer:@[@"A. 有，且出现次数频繁",@"B. 久坐才会出现",@"C. 无明显声响"]];
    [self addQuestion:@"2. 腰部前屈可达到90°" andAnswer:@[@"A. 未能达90°",@"B. 勉强做到",@"C. 轻松做到"]];
    [self addQuestion:@"3. 腰部后伸可达到30°" andAnswer:@[@"A. 未能达90°",@"B. 勉强做到",@"C. 轻松做到"]];
    [self addQuestion:@"4. 腰部侧屈可达到40°" andAnswer:@[@"A. 未能达90°",@"B. 勉强做到",@"C. 轻松做到"]];
    [self addQuestion:@"5. 扭动腰部，有无骨关节摩擦音及韧带滑动弹响声" andAnswer:@[@"A. 未能达90°",@"B. 勉强做到",@"C. 轻松做到"]];
    
    //膝关节
    [self addQuestion:@"1. 膝关节有无压痛点" andAnswer:@[@"A. 有，且不压就感觉到痛",@"B. 有，但压痛不明显",@"C. 无明显压痛点"]];
    [self addQuestion:@"2. 膝关节活动时，有无骨摩擦感或弹响声" andAnswer:@[@"A. 有，且明显",@"B. 偶尔才会出现",@"C. 无明显声响"]];
    [self addQuestion:@"3. 肢伸直，按压髌骨并使其在髌骨关节面向上、下、左、右地移动，有无感受到摩擦音或痛感" andAnswer:@[@"A. 有，且明显",@"B. 偶尔才会出现",@"C. 无明显僵硬酸痛"]];
    [self addQuestion:@"4. 膝关节可以伸直到180°" andAnswer:@[@"A. 未达到180°",@"B. 勉强做到",@"C. 轻松做到"]];
    [self addQuestion:@"5. 屈膝时，旋转范围可在15°~25°之间" andAnswer:@[@"A. 未能达15°",@"B. 勉强做到",@"C. 轻松做到"]];

    surveyController = [[GWQuestionnaire alloc] initWithItems:questions];
    surveyController.view.frame = CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-20);
    [self.view addSubview:surveyController.view];
}

#pragma mark - 颈椎问题表 -
- (void)createCervicalVertebraQuestionaire
{
    questions = [NSMutableArray array];
    //颈部
    [self addQuestion:@"1. 疼痛强度" andAnswer:@[@"A. 我此刻没有疼痛",@"B. 此刻疼痛非常轻微",@"C. 此刻有中等程度的疼痛",@"D. 此刻疼痛相当严重",@"E. 此刻疼痛非常严重",@"F. 此刻疼痛难以想象"]];
    [self addQuestion:@"2. 个人护理（洗漱、穿衣等等）" andAnswer:@[@"A. 我可以正常照顾自己，而不会引起额外的疼痛",@"B. 我可以正常照顾自己，但会引起额外的疼痛",@"C. 在照顾自己的时候会出现疼痛，我得小心地进行",@"D. 我的日常生活需要一些帮助",@"E. 我的大多数日常生活活动每天都需要照顾",@"F. 我不能穿衣，洗漱也很困难，不得不卧床"]];
    [self addQuestion:@"3. 提起重物" andAnswer:@[@"A. 我可以提起重物，且不引起任何额外的疼痛",@"B. 我可以提起重物，但会引起任何额外的疼痛",@"C. 重物放在桌子上合适的位置时，我会设法提起",@"D. 疼痛会妨碍我，但我可以提起中等重量的物体",@"E. 我可以提起轻的物体",@"F. 我不能提起或搬动任何物体"]];
    [self addQuestion:@"4. 阅读" andAnswer:@[@"A. 我可以随意阅读，而不会引起颈痛",@"B. 我可以随意阅读，但会引起轻度颈痛",@"C. 我可以随意阅读，但会引起中度颈痛",@"D. 因中度的颈痛，使得我不能随意阅读",@"E. 因重度的颈痛，使得我阅读困难",@"F. 我完全不能阅读"]];
    [self addQuestion:@"5. 头痛" andAnswer:@[@"A. 我完全没有头痛",@"B. 我有轻微的头痛，但不经常发生",@"C. 我有中度头痛，但不经常发生",@"D. 我有中度头痛，且经常发生",@"E. 我有严重的头痛，且经常发生",@"F. 我几乎一直都有头痛"]];
    [self addQuestion:@"6. 集中注意力" andAnswer:@[@"A. 我可以完全集中注意力，并且没有任何困难",@"B. 我可以完全集中注意力，但有轻微的困难",@"C. 当我想完全集中注意力时，有一定程度的困难",@"D. 当我想完全集中注意力时，有较多的困难",@"E. 当我想完全集中注意力时，有很大的困难",@"F. 我完全不能集中注意力"]];
    [self addQuestion:@"7. 工作" andAnswer:@[@"A. 我可以做很多我想做的工作",@"B. 我可以做多数日常的工作，但不能太多",@"C. 我只能做一部分日常的工作",@"D. 我不能做我的日常工作",@"E. 我几乎不能工作",@"F. 我任何工作都无法做"]];
    [self addQuestion:@"8. 睡觉" andAnswer:@[@"A. 我睡眠没有问题",@"B. 我的睡眠稍受影响（失眠，少于1小时）",@"C. 我的睡眠轻度受影响（失眠，1-2小时）",@"D. 我的睡眠中度受影响（失眠，2-3小时）",@"E. 我的睡眠重度受影响（失眠，3-5小时）",@"F. 我的睡眠完全受影响（失眠，5-7小时）"]];
    [self addQuestion:@"9. 驾驶" andAnswer:@[@"A. 我能驾驶而没有任何颈痛",@"B. 我想驾驶就可以驾驶，但仅有轻微颈痛",@"C. 我想驾驶就可以驾驶，但有中度颈痛",@"D. 我想驾驶，但不能驾驶，因有中度颈痛",@"E. 因严重的颈痛，我几乎不能驾驶",@"F. 因颈痛，我一点都不能驾驶"]];
    [self addQuestion:@"10. 娱乐" andAnswer:@[@"A. 我能从事我所有的娱乐活动，没有颈痛",@"B. 我能从事我所有的娱乐活动，但有一些颈痛",@"C. 因颈痛，我只能从事大部分的娱乐活动",@"D. 因颈痛，我只能从事少量的娱乐活动",@"E. 因颈痛，我几乎不能参与任何娱乐活动",@"F. 我不能参与任何娱乐活动"]];
    
    surveyController = [[GWQuestionnaire alloc] initWithItems:questions];
    surveyController.view.frame = CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-20);
    [self.view addSubview:surveyController.view];
}

#pragma mark - 腰椎问题表 -
- (void)createLumbarVertebraQuestionaire
{
    questions = [NSMutableArray array];
    //颈部
    [self addQuestion:@"1. 疼痛的程度（腰背痛或腿痛） " andAnswer:@[@"A. 无任何疼痛。",@"B. 有很稍微的痛。",@"C. 较明显的痛（中度）",@"D. 明显的痛（相当严重）",@"E. 严重的痛（非常严重）",@"F. 痛得不能做任何事"]];
    [self addQuestion:@"2. 日常生活自理能力（洗漱、穿脱衣服等活动）" andAnswer:@[@"A. 日常生活完全能自理，一点也不伴腰背痛或腿痛",@"B. 日常生活完全能自理，但引起腰背痛或腰痛加重",@"C. 要小心缓慢地进行日常活动",@"D. 多数日常活动可自理，有的需他人帮助",@"E. 绝大多数的日常活动需要他人帮助",@"F. 穿脱衣服、洗漱困难，只能躺在床上"]];
    [self addQuestion:@"3. 提物" andAnswer:@[@"A. 提重物时并不引起腰背或腿痛加重",@"B. 能提重物时，但腰背或腿痛加重",@"C. 重物放在桌子上合适的位置时，我会设法提起",@"D. 疼痛会妨碍我，但我可以提起中等重量的物体",@"E. 只能拿一点轻的东西",@"F. 任何东西都提不起来或拿不动"]];
    [self addQuestion:@"4. 行走" andAnswer:@[@"A. 腰背或腿不妨碍走多远",@"B. 由于腰背或腿痛，最多只能走1000米",@"C. 由于腰背或腿痛，最多只能走500米",@"D. 由于腰背或腿痛，最多只能走100米",@"E. 只能借助拐仗或手仗行走",@"F. 不得不躺在床上，排便也只能用便盆"]];
    [self addQuestion:@"5. 坐" andAnswer:@[@"A. 随便多高的椅子，想坐多久，就坐多久",@"B. 只要椅子高矮合适，想坐多久，就坐多久",@"C. 由于疼痛加重，最多只能坐1个小时",@"D. 由于疼痛加重，最多只能坐半个小时",@"E. 由于疼痛加重，最多只能坐10分钟",@"F. 由于疼痛加重，一点也不敢坐"]];
    [self addQuestion:@"6. 站立" andAnswer:@[@"A. 想站多久，就站多久，疼痛不会加重",@"B. 想站多久，就站多久，但疼痛有些加重",@"C. 由于疼痛加重，最多只能站1小时",@"D. 由于疼痛加重，最多只能站半小时",@"E. 由于疼痛加重，最多只能站10分钟",@"F. 由于疼痛加重，一点也不敢站"]];
    [self addQuestion:@"7. 睡眠" andAnswer:@[@"A. 半夜不会痛醒",@"B. 有时晚上会被痛醒",@"C. 由于疼痛，最多只能睡6个小时",@"D. 由于疼痛，最多只能睡4个小时",@"E. 由于疼痛，最多只能睡2个小时",@"F. 由于疼痛，根本无法入睡"]];
    [self addQuestion:@"8. 性生活" andAnswer:@[@"A. 性生活完全正常，决不会导致疼痛加重",@"B. 性生活完全正常，但会加重疼痛",@"C. 性生活基本正常，但有轻微地痛",@"D. 性生活基本正常，但会很痛",@"E. 由于疼痛，性生活严重受限",@"F. 由于疼痛，基本没有性生活"]];
    [self addQuestion:@"9. 社会活动" andAnswer:@[@"A. 社会活动完全正常，不会因此疼痛加重",@"B. 社会活动完全正常，但会加重疼痛",@"C. 疼痛限制剧烈活动，如运动",@"D. 疼痛限制参加社会活动，只能在家从事",@"E. 只能借助拐仗或手仗行走。 一些社会活动",@"F. 由于疼痛，根本无法从事任何社会活动"]];
    [self addQuestion:@"10. 旅行(郊游) " andAnswer:@[@"A. 能到任何地方去旅行，腰部或腿不会痛",@"B. 能到任何地方去旅行，但疼痛会加重",@"C. 由于疼痛，外出郊游不超过2小时",@"D. 由于疼痛，外出郊游不超过1小时",@"E. 由于疼痛，外出郊游不超过30分钟",@"F. 由于疼痛，除了到医院，根本无法外出"]];
    
    surveyController = [[GWQuestionnaire alloc] initWithItems:questions];
    surveyController.view.frame = CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-20);
    [self.view addSubview:surveyController.view];
}

- (void)bindViewModel
{
    [super bindViewModel];
//    [self createCervicalVertebraQuestionaire];
//    [RACObserve(surveyController, surveyItems) subscribeNext:^(NSMutableArray * x) {
//        if ([surveyController isCompleted]) {
//            self.viewModel.questionaireCompleted = YES;
//            self.viewModel.surveyItems = [NSMutableArray arrayWithArray:x];
//        }
//        else
//        {
//            self.viewModel.questionaireCompleted = NO;
//        }
//    }];
}

- (void)addSurvey
{
    questions = [NSMutableArray array];
    
    NSDictionary *question1Answer1 = [NSDictionary dictionaryWithObjectsAndKeys:@"A. 有，且出现次数频繁",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *question1Answer2 = [NSDictionary dictionaryWithObjectsAndKeys:@"B. 久坐才会出现",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *question1Answer3 = [NSDictionary dictionaryWithObjectsAndKeys:@"C. 无明显声响",@"text",[NSNumber numberWithBool:NO],@"marked", nil];

    NSDictionary *question2Answer1 = [NSDictionary dictionaryWithObjectsAndKeys:@"A. 未能达90°",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *question2Answer2 = [NSDictionary dictionaryWithObjectsAndKeys:@"B. 勉强做到",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *question2Answer3 = [NSDictionary dictionaryWithObjectsAndKeys:@"C. 轻松做到",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    
    NSDictionary *question5Answer1 = [NSDictionary dictionaryWithObjectsAndKeys:@"A. 有，且明显",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *question5Answer2 = [NSDictionary dictionaryWithObjectsAndKeys:@"B. 偶尔过度疲劳才会出现",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    NSDictionary *question5Answer3 = [NSDictionary dictionaryWithObjectsAndKeys:@"C. 无明显声响",@"text",[NSNumber numberWithBool:NO],@"marked", nil];
    
    GWQuestionnaireItem *item = [[GWQuestionnaireItem alloc] initWithQuestion:@"1. 坐立时腰部会出现疼痛症状"
                                                                      answers:[NSArray arrayWithObjects:question1Answer1,question1Answer2,question1Answer3, nil]
                                                                         type:GWQuestionnaireSingleChoice];
    [questions addObject:item];
    
    item = [[GWQuestionnaireItem alloc] initWithQuestion:@"2. 腰部前屈是否可达到90°"
                                                 answers:[NSArray arrayWithObjects:question2Answer1,question2Answer2,question2Answer3, nil]
                                                    type:GWQuestionnaireSingleChoice];
    [questions addObject:item];
    
    item = [[GWQuestionnaireItem alloc] initWithQuestion:@"3. 腰部后伸是否可达到30°"
                                                 answers:[NSArray arrayWithObjects:question2Answer1,question2Answer2,question2Answer3, nil]
                                                    type:GWQuestionnaireSingleChoice];
    [questions addObject:item];
    
    item = [[GWQuestionnaireItem alloc] initWithQuestion:@"4. 腰部侧屈是否可达到40°"
                                                 answers:[NSArray arrayWithObjects:question2Answer1,question2Answer2,question2Answer3, nil]
                                                    type:GWQuestionnaireSingleChoice];
    [questions addObject:item];

    item = [[GWQuestionnaireItem alloc] initWithQuestion:@"5. 扭动腰部，有无骨关节摩擦音及韧带滑动弹响声"
                                                 answers:[NSArray arrayWithObjects:question5Answer1,question5Answer2,question5Answer3, nil]
                                                    type:GWQuestionnaireSingleChoice];
    [questions addObject:item];


    surveyController = [[GWQuestionnaire alloc] initWithItems:questions];
    surveyController.view.frame = CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-20);
    [self.view addSubview:surveyController.view];
    
    
    // add button
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btn setTitle:NSLocalizedString(@"Get answers!", nil) forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(getAnswersPressed:) forControlEvents:UIControlEventTouchUpInside];
    int btnW = 150;
    int btnX = (self.view.frame.size.width - btnW)/2;
    [btn setFrame:CGRectMake(btnX, self.view.frame.size.height - 40, btnW, 40)];
    [self.view addSubview:btn];
}

-(void)getAnswersPressed:(id)sender
{
    if(![surveyController isCompleted])
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"请填完问卷再提交" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        return;
    }
    else
    {
        @weakify(self);
        [MBProgressHUD showHUDinKeyWindow];
        self.viewModel.questionaireCompleted = YES;
        self.viewModel.surveyItems = [NSMutableArray arrayWithArray:surveyController.surveyItems];
        [[self.viewModel submitTheArray] subscribeNext:^(id x) {
            [MBProgressHUD hideHUDinKeyWindow];
            @strongify(self);
            NSMutableArray * viewArray = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
            [viewArray removeAllObjects];
            for (int i = 0; i < self.navigationController.viewControllers.count-1; i++) {
                [viewArray addObject:self.navigationController.viewControllers[i]];
            }
            if (self.viewModel.testType == TESTTYPECERVICALVERTEBRA) {
                [self showNeckTrainingProjectWithViewArray:viewArray
                                                dataSource:x];
            }
            else if (self.viewModel.testType == TESTTYPELUMBARVERTEBRA) {
                [self showWaistTrainingProjectWithViewArray:viewArray
                                                 dataSource:x];
            }
        }];
    }
}

#pragma mark - 颈部测试结果
- (void)showNeckTrainingProjectWithViewArray:(NSMutableArray *)viewArray
                                  dataSource:(NSArray *)dataSource
{
    @weakify(self);
    NSString * alertString;
    switch ([APIService shareService].spineTestData.neckPoint) {
        case 1:
        {
            alertString = @"您现在颈椎状况良好，请继续保持";
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:alertString
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * x) {
                [self.navigationController popToRootViewControllerAnimated:YES];
            }];
            [alertView show];
        }
            break;
        case 2:
        {
            alertString = @"您现在处于轻度颈椎损伤状态，可以配合我们的恢复视频进行治疗";
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:alertString
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * index) {
                @strongify(self);
                SpecificTrainingViewModel * viewModel = [[SpecificTrainingViewModel alloc] init];
                [viewModel.dataSource addObjectsFromArray:dataSource];
                viewModel.trainingPart = 0;
                viewModel.severity = [APIService shareService].spineTestData.neckPoint;
                SpecificTrainingViewController * vc = [[SpecificTrainingViewController alloc] initWithViewModel:viewModel];
                [viewArray addObject:vc];
                [self.navigationController setViewControllers:viewArray animated:YES];
            }];
            [alertView show];
        }
            break;
        case 3:
        {
            alertString = @"您现在处于中度颈椎损伤状态，可以配合我们的恢复视频进行治疗";
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:alertString
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * index) {
                @strongify(self);
                SpecificTrainingViewModel * viewModel = [[SpecificTrainingViewModel alloc] init];
                [viewModel.dataSource addObjectsFromArray:dataSource];
                viewModel.trainingPart = 0;
                viewModel.severity = [APIService shareService].spineTestData.neckPoint;
                SpecificTrainingViewController * vc = [[SpecificTrainingViewController alloc] initWithViewModel:viewModel];
                [viewArray addObject:vc];
                [self.navigationController setViewControllers:viewArray animated:YES];
            }];
            [alertView show];
        }
            break;
        default:
        {
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"您的颈椎受损程度较高，建议前往医院进行治疗"
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * x) {
                [self.navigationController popToRootViewControllerAnimated:YES];
            }];
            [alertView show];
        }
            break;
    }
}

#pragma mark - 腰部测试结果
- (void)showWaistTrainingProjectWithViewArray:(NSMutableArray *)viewArray
                                   dataSource:(NSArray *)dataSource
{
    @weakify(self);
    NSString * alertString;
    switch ([APIService shareService].spineTestData.waistPoint) {
        case 1:
        {
            alertString = @"您现在腰椎状况良好，请继续保持";
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:alertString
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * x) {
                [self.navigationController popToRootViewControllerAnimated:YES];
            }];
            [alertView show];
        }
            break;
        case 2:
        {
            alertString = @"您现在处于轻度腰椎损伤状态，可以配合我们的恢复视频进行治疗";
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:alertString
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * index) {
                @strongify(self);
                SpecificTrainingViewModel * viewModel = [[SpecificTrainingViewModel alloc] init];
                [viewModel.dataSource addObjectsFromArray:dataSource];
                viewModel.trainingPart = 1;
                viewModel.severity = [APIService shareService].spineTestData.waistPoint;
                SpecificTrainingViewController * vc = [[SpecificTrainingViewController alloc] initWithViewModel:viewModel];
                [viewArray addObject:vc];
                [self.navigationController setViewControllers:viewArray animated:YES];
            }];
            [alertView show];
        }
            break;
        case 3:
        {
            alertString = @"您现在处于中度腰椎损伤状态，可以配合我们的恢复视频进行治疗";
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:alertString
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * index) {
                @strongify(self);
                SpecificTrainingViewModel * viewModel = [[SpecificTrainingViewModel alloc] init];
                [viewModel.dataSource addObjectsFromArray:dataSource];
                viewModel.trainingPart = 1;
                viewModel.severity = [APIService shareService].spineTestData.waistPoint;
                SpecificTrainingViewController * vc = [[SpecificTrainingViewController alloc] initWithViewModel:viewModel];
                [viewArray addObject:vc];
                [self.navigationController setViewControllers:viewArray animated:YES];
            }];
            [alertView show];
        }
            break;
        default:
        {
            UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"您的腰椎受损程度较高，建议前往医院进行治疗"
                                                                 message:nil
                                                                delegate:nil
                                                       cancelButtonTitle:@"确定"
                                                       otherButtonTitles:nil, nil];
            [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber * x) {
                [self.navigationController popToRootViewControllerAnimated:YES];
            }];
            [alertView show];
        }
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
